<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <link rel="stylesheet" href="/after/css/bootstrap.min.css">
    <link rel="stylesheet" href="/after/css/laypage.css">
    <script type="text/javascript" src="/after/js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="/after/js/laypage/laypage.js"></script>
    <script type="text/javascript" src="/after/js/layer/layer.js"></script>
    <script type="text/javascript" src="/after/js/vue/vue.min.js"></script>
</head>
<style>
    input.error {
        border: 1px solid red;
    }
</style>
<body>
<div id="app">
<div class="container">
    <form id="addUserForm" type="post" enctype="multipart/form-data">
        <br/>
            <input type="hidden" class="form-control" value="${id}" name="id" placeholder="输入活动名称">
        <div class="form-group">
            <label for="content">修改权限：</label>
            <select id="type">
                <#list role as r>
                    <option value="${r.id}">${r.role}</option>
                </#list>
            </select>
        </div>

        <div class="form-group">
            <button type="button" id="saveBtn" class="btn btn-success">提交</button>
            <button type="button" id="cancelBtn" class="btn btn-default">取消</button>
        </div>
    </form>
</div>
</div>
</body>
</html>

<script>

    var app = new Vue({
        el:'#app',
        data:{
            role:[]
        }
    })

    var addActive = function(){
        $.ajax({
            type: 'GET',
            dataType: 'json',
            url: '/role/updateRole.do',
            data: {
               id:$(":input[name='id']").val(),
               rid:$("#type").val()
            },
            success: function (msg) {
                $("#cancelBtn").click();
            }
        });
    }

    //点击添加，调用addUser()功能
    $("#saveBtn").on("click",function(){
        addActive();
    })

    $("#cancelBtn").on("click", function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.getRolePageList();
        parent.layer.close(index);
    })
</script>